<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=0">
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<link rel="stylesheet" type="text/css" href="../../css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="../../css/style.css"/>
<link rel="stylesheet" type="text/css" href="../../css/loaders.css"/>
<script type="text/javascript" src="../../js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="../../js/common.js"></script>
<script type="text/javascript" src="../../js/config.js"></script>
<script type="text/javascript" src="../../js/iscroll.js"></script>
<title>游戏·列表</title>
</head>
<body>
<div class="container-fluid" style="position: relative">

	<div class="row swiper-box" id="wrapper">
	<div class="row download-top scroll" id="header">
		<div class="gameTypeloading">
			<div class="loader-inner line-scale">
				<div></div>
				<div></div>
				<div></div>
				<div></div>
				<div></div>
			</div>
		</div>
	</div>
		</div>
	<div class="row" id='class1'>
		<div class="col-xs-12" id="gamelist">
             <div class="gameLoading">
				 <div class="loader-inner pacman">
					 <div></div>
					 <div></div>
					 <div></div>
					 <div></div>
					 <div></div>
				 </div>
				 <p>别着急,伦家正在火速赶来啦</p>
			 </div>

		</div>
	</div>
	<footer>
		<div class="col-xs-3 col-xs-offset-2">
			<a href="../index/index.html" class="btn_1"></a>
		</div>
		<div class="col-xs-3">
			<a href="index.html" class="btn_2_yes"></a>
		</div>
		<div class="col-xs-3">
			<a href="../set/index.html" class="btn_3"></a>
		</div>
	</footer>
</div>
</body>
</html>
<script type="text/javascript">
//	var header = document.getElementById('header');
//	var typebox = document.getElementsByClassName('typebox');
//	header.style.width = typebox[0].offsetWidth*typebox.length+'px';
//	var Scroll = new iScroll('wrapper',{hScrollbar:false, vScrollbar:false});

    function getGameList(obj){
		var Type = obj.getAttribute("data-type") ;
		var typebox = document.getElementById("header").getElementsByTagName('a');

		for(var i=0;i<typebox.length;i++){
			  typebox[i].className = '';

		}
		obj.className = 'active';
		loadGameList(Type);
	}

    load();
	function load(data){
		var url = "http://aaa.57810.mom/index.php/Game/index";
		if (data==''){
			 data = '';
		}else{
			 data = {gtype:data};
		}
		$.ajax({
			type : "get",
			url : url,
			dataType : "jsonp",
			data:data,
			jsonp: "callback",//传递给请求处理程序或页面的，用以获得jsonp回调函数名的参数名(默认为:callback)
			jsonpCallback:"success_jsonpCallback",//自定义的jsonp回调函数名称，默认为jQuery自动生成的随机函数名
			success : function(json){
				console.log(json);
				var type = document.getElementById("header");
				var gameList = document.getElementById('gamelist');
				var TypeHtml = "";
				for(var i=0;i<json['gameType'].length;i++){
					  if(i==0){
						  TypeHtml+='<div class="typebox"><a href="javascript:;" class="active" onclick="getGameList(this)" data-type='+json['gameType'][i]['gameType']+'>'+json['gameType'][i]['gameTypeName']+'</a></div>';
					  }else {
						  TypeHtml += '<div class="typebox"><a href="javascript:;" onclick="getGameList(this)" data-type=' + json['gameType'][i]['gameType'] + '>' + json['gameType'][i]['gameTypeName'] + '</a></div>';
					  }
				}
				var GameHtml = "";
				for(var i=0;i<json['gameList'].length;i++){
					  GameHtml+='<div class="download-list"><img src="http://115.29.42.246:8080/kuyun/'+json['gameList'][i]['gameImgUri']+'"/><a href="./info.html?gameId='+json['gameList'][i]['id']+'">'+json['gameList'][i]['gameTitle']+'<p>'+json['gameList'][i]['gameDescription']+'</p></a><a href="./info.html?gameId='+json['gameList'][i]['id']+'" class="downBtn">'+json['gameList'][i]['gameSize']+'M</a></div>'
				}
				gameList.innerHTML = GameHtml;
				type.innerHTML = TypeHtml;

			},
			error:function(){
				alert('fail');
			}
		});
	}

function loadGameList(data){
	var url = "http://aaa.57810.mom/index.php/Game/index";
	if (data==''){
		data = '';
	}else{
		data = {gtype:data};
	}
	$.ajax({
		type : "get",
		url : url,
		dataType : "jsonp",
		data:data,
		jsonp: "callback",//传递给请求处理程序或页面的，用以获得jsonp回调函数名的参数名(默认为:callback)
		jsonpCallback:"success_jsonpCallback",//自定义的jsonp回调函数名称，默认为jQuery自动生成的随机函数名
		success : function(json){
			var gameList = document.getElementById('gamelist');
			var GameHtml = "";
			for(var i=0;i<json['gameList'].length;i++){
				GameHtml+='<div class="download-list"><img src="http://115.29.42.246:8080/kuyun/'+json['gameList'][i]['gameImgUri']+'"/><a href="./info.html?gameId='+json['gameList'][i]['id']+'">'+json['gameList'][i]['gameTitle']+'<p>'+json['gameList'][i]['gameDescription']+'</p></a><a href="./info.html?gameId='+json['gameList'][i]['id']+'" class="downBtn">'+json['gameList'][i]['gameSize']+'M</a></div>'
			}
			gameList.innerHTML = GameHtml;
		},
		error:function(){
			alert('fail');
		}
	});
}

</script>